using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using STD.Shared.Common.Enums;

namespace STD.Shared.Infrastructure.Database;

/// <summary>
/// 数据库提供者接口
/// </summary>
public interface IDatabaseProvider
{
    /// <summary>
    /// 数据库类型
    /// </summary>
    DatabaseType DatabaseType { get; }
    
    /// <summary>
    /// 配置DbContext
    /// </summary>
    /// <param name="optionsBuilder">DbContext选项构建器</param>
    /// <param name="connectionString">连接字符串</param>
    void ConfigureDbContext(DbContextOptionsBuilder optionsBuilder, string connectionString);
    
    /// <summary>
    /// 获取连接字符串
    /// </summary>
    /// <param name="configuration">配置</param>
    /// <param name="sectionName">配置节名称</param>
    /// <returns>连接字符串</returns>
    string GetConnectionString(IConfiguration configuration, string sectionName);
    
    /// <summary>
    /// 验证连接
    /// </summary>
    /// <param name="connectionString">连接字符串</param>
    /// <returns>是否连接成功</returns>
    Task<bool> ValidateConnectionAsync(string connectionString);
} 